//
//  HotSpotsViewController.m
//  TravelOcean
//
//  Created by double Mac on 15/3/7.
//  Copyright (c) 2015年 double Mac. All rights reserved.
//

#import "HotSpotsViewController.h"

@interface HotSpotsViewController ()

@end

@implementation HotSpotsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"热点专题";
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"399-list1@3x.png"] style:UIBarButtonItemStylePlain target:self action:@selector(leftBarButtonAction:)];
    
    HotSpotsView *hotView = [[HotSpotsView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 49 - 64)];
    [self.view addSubview:hotView];
    [hotView release];
    
    self.allSpotArr = [NSMutableArray array];
    
    UrlGetTool *download = [[UrlGetTool alloc] init];
    [download downloadBlock:@"http://mobileapp.roadqu.com/api/mobile/qunawan/tour/featuredthemeslist?token=54f7bc5bdf8d7&a_t=1425523425881&sign=452bd3973417303ed51015a8d317ddd08f1b695d" block:^(id result) {
        
        NSMutableArray *spotArr = [result objectForKey:@"data"];
        
        for (NSDictionary *dic in spotArr) {
            HotSpots *hotSpot = [[HotSpots alloc] init];
            [hotSpot setValuesForKeysWithDictionary:dic];
            [self.allSpotArr addObject:hotSpot];
            
        }
        
        HotSpots *hotSpot1 = [self.allSpotArr objectAtIndex:0];
        [hotView.view1 sd_setImageWithURL:[NSURL URLWithString:hotSpot1.img] placeholderImage:[UIImage imageNamed:@"cts_icon_add_train_background@2x.png"]];
//        hotView.label1.text = hotSpot1.name;
        
        UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap1Action:)];
        [hotView.view1 addGestureRecognizer:tap1];
        [tap1 release];
        
        
        HotSpots *hotSpot2 = [self.allSpotArr objectAtIndex:1];
        [hotView.view2 sd_setImageWithURL:[NSURL URLWithString:hotSpot2.img] placeholderImage:[UIImage imageNamed:@"cts_icon_add_train_background@2x.png"]];
//        hotView.label2.text = hotSpot2.name;
        
        HotSpots *hotSpot3 = [self.allSpotArr objectAtIndex:2];
        [hotView.view3 sd_setImageWithURL:[NSURL URLWithString:hotSpot3.img] placeholderImage:[UIImage imageNamed:@"cts_icon_add_train_background@2x.png"]];
//        hotView.label3.text = hotSpot3.name;
        
        HotSpots *hotSpot4 = [self.allSpotArr objectAtIndex:3];
        [hotView.view4 sd_setImageWithURL:[NSURL URLWithString:hotSpot4.img] placeholderImage:[UIImage imageNamed:@"cts_icon_add_train_background@2x.png"]];
//        hotView.label4.text = hotSpot4.name;
        
//        HotSpots *hotSpot5 = [self.allSpotArr objectAtIndex:4];
//        [hotView.view5 sd_setImageWithURL:[NSURL URLWithString:hotSpot5.img] placeholderImage:[UIImage imageNamed:@"cts_icon_add_train_background@2x.png"]];
//        hotView.label5.text = hotSpot5.name;
//        
//        HotSpots *hotSpot6 = [self.allSpotArr objectAtIndex:5];
//        [hotView.view6 sd_setImageWithURL:[NSURL URLWithString:hotSpot6.img] placeholderImage:[UIImage imageNamed:@"cts_icon_add_train_background@2x.png"]];
//        hotView.label6.text = hotSpot6.name;
//        
//        HotSpots *hotSpot7 = [self.allSpotArr objectAtIndex:6];
//        [hotView.view7 sd_setImageWithURL:[NSURL URLWithString:hotSpot7.img] placeholderImage:[UIImage imageNamed:@"cts_icon_add_train_background@2x.png"]];
//        hotView.label7.text = hotSpot7.name;
        
        HotSpots *hotSpot8 = [self.allSpotArr objectAtIndex:7];
        [hotView.view8 sd_setImageWithURL:[NSURL URLWithString:hotSpot8.img] placeholderImage:[UIImage imageNamed:@"cts_icon_add_train_background@2x.png"]];
//        hotView.label8.text = hotSpot8.name;
        
        HotSpots *hotSpot9 = [self.allSpotArr objectAtIndex:8];
        [hotView.view9 sd_setImageWithURL:[NSURL URLWithString:hotSpot9.img] placeholderImage:[UIImage imageNamed:@"cts_icon_add_train_background@2x.png"]];
//        hotView.label9.text = hotSpot9.name;
        
        HotSpots *hotSpot10 = [self.allSpotArr objectAtIndex:9];
        [hotView.view10 sd_setImageWithURL:[NSURL URLWithString:hotSpot10.img] placeholderImage:[UIImage imageNamed:@"cts_icon_add_train_background@2x.png"]];
//        hotView.label10.text = hotSpot10.name;
        
        HotSpots *hotSpot14 = [self.allSpotArr objectAtIndex:10];
        [hotView.view14 sd_setImageWithURL:[NSURL URLWithString:hotSpot14.img] placeholderImage:[UIImage imageNamed:@"cts_icon_add_train_background@2x.png"]];
//        hotView.label14.text = hotSpot14.name;
        
    }];
    
    UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap1Action:)];
    [tap1 release];
    
    
    UIButton *summer = [UIButton buttonWithType:UIButtonTypeCustom];
    summer.frame = CGRectMake(0, hotView.view10.frame.origin.y + hotView.view10.frame.size.height + 45, 125, 50);
    summer.backgroundColor = [UIColor greenColor];
    [summer setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [summer setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
    [summer setTitle:@"夏" forState:UIControlStateNormal];
    [hotView addSubview:summer];
    [summer addTarget:self action:@selector(summerAction:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *autumn = [UIButton buttonWithType:UIButtonTypeCustom];
    autumn.frame = CGRectMake(125, hotView.view10.frame.origin.y + hotView.view10.frame.size.height + 45, 125, 50);
    autumn.backgroundColor = [UIColor orangeColor];
    [autumn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [autumn setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
    [autumn setTitle:@"秋" forState:UIControlStateNormal];
    [hotView addSubview:autumn];
    [autumn addTarget:self action:@selector(autumnAction:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *winter = [UIButton buttonWithType:UIButtonTypeCustom];
    winter.frame = CGRectMake(250, hotView.view10.frame.origin.y + hotView.view10.frame.size.height + 45, 125, 50);
    winter.backgroundColor = [UIColor cyanColor];
    [winter setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [winter setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
    [winter setTitle:@"冬" forState:UIControlStateNormal];
    [hotView addSubview:winter];
    [winter addTarget:self action:@selector(winterAction:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
    button1.frame = CGRectMake(35, hotView.sView.frame.origin.y + hotView.sView.frame.size.height + 10, 80, 80);
    button1.backgroundColor = [UIColor cyanColor];
    [button1 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [button1 setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
    [button1 setTitle:@"樱花" forState:UIControlStateNormal];
    [hotView addSubview:button1];
    [button1 addTarget:self action:@selector(winterAction:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *button2 = [UIButton buttonWithType:UIButtonTypeCustom];
    button2.frame = CGRectMake(150, hotView.sView.frame.origin.y + hotView.sView.frame.size.height + 10, 80, 80);
    button2.backgroundColor = [UIColor cyanColor];
    [button2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [button2 setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
    [button2 setTitle:@"古镇" forState:UIControlStateNormal];
    [hotView addSubview:button2];
    [button2 addTarget:self action:@selector(winterAction:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *button3 = [UIButton buttonWithType:UIButtonTypeCustom];
    button3.frame = CGRectMake(265, hotView.sView.frame.origin.y + hotView.sView.frame.size.height + 10, 80, 80);
    button3.backgroundColor = [UIColor cyanColor];
    [button3 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [button3 setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
    [button3 setTitle:@"温泉" forState:UIControlStateNormal];
    [hotView addSubview:button3];
    [button3 addTarget:self action:@selector(winterAction:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *button4 = [UIButton buttonWithType:UIButtonTypeCustom];
    button4.frame = CGRectMake(35, hotView.view4.frame.origin.y + hotView.view4.frame.size.height + 10, 80, 80);
    button4.backgroundColor = [UIColor cyanColor];
    [button4 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [button4 setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
    [button4 setTitle:@"樱花" forState:UIControlStateNormal];
    [hotView addSubview:button4];
    [button4 addTarget:self action:@selector(winterAction:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *button5 = [UIButton buttonWithType:UIButtonTypeCustom];
    button5.frame = CGRectMake(150, hotView.view4.frame.origin.y + hotView.view4.frame.size.height + 10, 80, 80);
    button5.backgroundColor = [UIColor cyanColor];
    [button5 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [button5 setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
    [button5 setTitle:@"古镇" forState:UIControlStateNormal];
    [hotView addSubview:button5];
    [button5 addTarget:self action:@selector(winterAction:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *button6 = [UIButton buttonWithType:UIButtonTypeCustom];
    button6.frame = CGRectMake(265, hotView.view4.frame.origin.y + hotView.view4.frame.size.height + 10, 80, 80);
    button6.backgroundColor = [UIColor cyanColor];
    [button6 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [button6 setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
    [button6 setTitle:@"温泉" forState:UIControlStateNormal];
    [hotView addSubview:button6];
    [button6 addTarget:self action:@selector(winterAction:) forControlEvents:UIControlEventTouchUpInside];
    
    UIImageView *downView = [[UIImageView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 49 - 64, self.view.frame.size.width, 49)];
    downView.image = [UIImage imageNamed:@"navbar_bg@2x.png"];
    [self.view addSubview:downView];
    [downView release];
    
}

- (void)tap1Action:(UITapGestureRecognizer *)tap
{
    NSLog(@"............");
    HotSpots *spots = [self.allSpotArr objectAtIndex:1];
    SpotListViewController *spotListVC = [[SpotListViewController alloc] init];
    spotListVC.mtid = spots.name;
    [self.navigationController pushViewController:spotListVC animated:YES];
}

- (void)button1Action:(UIButton *)button
{
    NSLog(@"............");
    HotSpots *spots = [self.allSpotArr objectAtIndex:1];
    SpotListViewController *spotListVC = [[SpotListViewController alloc] init];
    spotListVC.mtid = spots.name;
    [self.navigationController pushViewController:spotListVC animated:YES];
}

- (void)summerAction:(UIButton *)button
{
    NSLog(@"............");
    HotSpots *spots = [self.allSpotArr objectAtIndex:1];
    SpotListViewController *spotListVC = [[SpotListViewController alloc] init];
    spotListVC.mtid = spots.name;
    [self.navigationController pushViewController:spotListVC animated:YES];
}

- (void)autumnAction:(UIButton *)button
{
    
}

- (void)winterAction:(UIButton *)button
{
    
}

- (void)leftBarButtonAction:(UIBarButtonItem *)barButton
{
    [[AppDelegate globalDelegate] toggleLeftDrawer:self animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
